package com.xxl.shoppingapp.base;

import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.support.annotation.NonNull;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
import com.xxl.shoppingapp.R;

import butterknife.Bind;

/**
 * Title: BaseRecyclerViewFragment.java
 * Description:
 * Copyright (c) 版权所有请勿抄袭 2018
 * Created DateTime: 2018/4/12 13:45
 * Created by xuelianx.
 */
public abstract class BaseRecyclerViewFragment extends BaseFragment {

    protected BaseRecyclerViewAdapter adapter;


    @Override
    protected int getLayout() {
        return R.layout.fragment_base_recycler;
    }

    @Bind(R.id.base_recycler_view_swipe)
    SmartRefreshLayout swipeRefreshLayout;

    @Bind(R.id.base_recycler_view)
    RecyclerView baseRecycler;

    public SmartRefreshLayout getSwipeRefreshLayout(){
        return  swipeRefreshLayout;
    }

    @Override
    protected void initView(View view) {
        super.initView(view);
        initAdapter();
        baseRecycler.setLayoutManager(new LinearLayoutManager(getBaseActivity()));
        baseRecycler.addItemDecoration(new DividerItemDecoration(getActivity(),DividerItemDecoration.VERTICAL));
        baseRecycler.setAdapter(adapter);

    }

    protected abstract void initAdapter();

    @Override
    protected void initData() {
        super.initData();
    }

}
